import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, mergeProps } from "vue";
var index_vue_vue_type_style_index_0_scoped_true_lang = "";
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _hoisted_1 = { class: "choose-date" };
const _hoisted_2 = { class: "start-date" };
const _hoisted_3 = { class: "end-date" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  name: "index",
  props: {
    startPlaceholder: { default: "\u8BF7\u9009\u62E9\u5F00\u59CB\u65F6\u95F4" },
    endPlaceholder: { default: "\u8BF7\u9009\u62E9\u7ED3\u675F\u65F6\u95F4" },
    disableBeforeToday: { type: Boolean, default: true }
  },
  emits: ["changeStartTime", "onChange"],
  setup(__props, { emit: emits }) {
    const props = __props;
    const startDate = ref(void 0);
    const endDate = ref(void 0);
    const endDateDisable = ref(true);
    const startDisabledDate = (time) => {
      if (props.disableBeforeToday)
        return time.getTime() < Date.now() - 1e3 * 60 * 60 * 24;
    };
    const endDisabledDate = (time) => {
      if (startDate.value)
        return time.getTime() < startDate.value.getTime() + 1e3 * 60 * 60 * 24;
    };
    watch(() => startDate.value, (val) => {
      if (!val) {
        endDateDisable.value = true;
        endDate.value = void 0;
        return;
      }
      endDateDisable.value = false;
      emits("changeStartTime", val);
    });
    watch(() => endDate.value, (val) => {
      val && emits("onChange", {
        startDate: startDate.value,
        endDate: val
      });
    });
    return (_ctx, _cache) => {
      const _component_el_date_picker = resolveComponent("el-date-picker");
      return openBlock(), createElementBlock("div", null, [
        createElementVNode("div", _hoisted_1, [
          createElementVNode("div", _hoisted_2, [
            createVNode(_component_el_date_picker, mergeProps({
              modelValue: startDate.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => startDate.value = $event),
              type: "date",
              placeholder: __props.startPlaceholder,
              "disabled-date": startDisabledDate
            }, _ctx.$attrs.startOptions), null, 16, ["modelValue", "placeholder"])
          ]),
          createElementVNode("div", _hoisted_3, [
            createVNode(_component_el_date_picker, mergeProps({
              modelValue: endDate.value,
              "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => endDate.value = $event),
              type: "date",
              placeholder: __props.endPlaceholder,
              "disabled-date": endDisabledDate
            }, _ctx.$attrs.endOptions, { disabled: endDateDisable.value }), null, 16, ["modelValue", "placeholder", "disabled"])
          ])
        ])
      ]);
    };
  }
});
var chooseDate = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-119050d1"]]);
var index = {
  install(app) {
    app.component("MnChooseDate", chooseDate);
  }
};
export { index as default };
